<template>
    <div>
      <el-form :model="queryParams" ref="queryForm" size="mini" label-width="68px">
        <el-row :gutter="20">
        <el-col :span="4">
          <el-form-item label="项目区域" prop="projectRegion">
            <el-select v-model="queryParams.projectRegion" placeholder="请选择" clearable
              @keyup.enter.native="handleQuery">
              <el-option v-for="dict in dict.type.cld_project_region" :key="dict.value" :label="dict.label"
                :value="parseInt(dict.value)"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="queryParams.projectName" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="时间区域" >
            <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd" type="daterange" range-separator="-"
              start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="10px">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
      </el-form>
      <el-table v-loading="loading" :data="list" border>
        <el-table-column label="日期" align="center" prop="materialAllocateDate" >
            <template slot-scope="scope">
              {{parseTime(scope.row.materialAllocateDate,'{y}-{m}-{d}')}}
            </template>
        </el-table-column>
        <el-table-column label="区域" align="center" prop="projectRegion" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cld_project_region" :value="scope.row.projectRegion"/>
        </template>
      </el-table-column>
        <el-table-column label="项目" align="center" prop="projectName" />
        <el-table-column label="商品编号" align="center" prop="commodityNo" />
        <el-table-column label="商品名称" align="center" prop="commodityName" />
        <el-table-column label="商品规格" align="center" prop="commoditySpec" />
        <el-table-column label="商品单位" align="center" prop="unitName" />
        <el-table-column label="调入数量" align="center" prop="transferNumber" />
        <el-table-column label="调入金额" align="center" prop="transferMoney" >
            <template slot-scope="scope">
              {{toMoney(scope.row.transferMoney)}}
            </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </template>

  <script>
  import { transferDetails } from '@/api/cld/materialStatistics'
  export default {
    name: "categoryStatistics",
    dicts: ['cld_project_region'  ],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 表格数据
        list: [],
        dateRange: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          projectRegion: null,
          projectName: null,
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        transferDetails(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
  </script>
